package cn.edu.suda.catalina.health;


import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.view.View;
import android.widget.TextView;

import cn.edu.suda.catalina.entity.Diary;

public class DiaryShowFragment extends DialogFragment {

    public static final String FRAGMENT_TAG = "diaryShow";

    private Diary mDiary;

    public DiaryShowFragment() {
    }

    public static DiaryShowFragment newInstance() {
        return new DiaryShowFragment();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_diary_show, null);
        TextView timeText = (TextView) view.findViewById(R.id.diary_show_time);
        TextView diaryText = (TextView) view.findViewById(R.id.diary_show_diary);

        if (mDiary != null) {
            timeText.setText(mDiary.getTime());
            diaryText.setText(mDiary.getDiary());
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AlertDialogTheme));
        builder.setView(view).setNegativeButton("确定", null);
        return builder.create();
    }

    public void setText(Diary diary) {
        mDiary = diary;
    }

}
